<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
if($_RQ['op']=='list'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'type'=>intval($_RQ['type']));
	$return['params']['type']=intval($_RQ['type']);
	if($_RQ['type']==10){
		$params['type']=1;
		$params['code_type']=0;
	}elseif($_RQ['type']==30){
		$params['type']=3;
		$params['code_type']=0;
	}
	if(!empty($_RQ['code'])){
		$params['code']='%'.trim($_RQ['code']).'%';
		$return['params']['code']=trim($_RQ['code']);
	}
	if(!empty($_RQ['sn'])){
		$params['sn like']='%'.trim($_RQ['sn']).'%';
		$return['params']['sn']=trim($_RQ['sn']);
	}
	if(!empty($_RQ['merchid'])){
		$params['merchid']=intval($_RQ['merchid']);
		$return['params']['merchid']=$_RQ['merchid'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$return['list']=pdo_getslice('jy_goodserpfw_merchlog',$params,array($pindex,$psize),$total,$fields,'','id desc');
	foreach($return['list'] as &$v){
		$v['merchname']=pdo_getcolumn('jy_merch_user',array('uniacid'=>$_SESSION['uniacid'],'id'=>$v['merchid']),'merchname');
		$v['member']=cfc('core')->member_show($v['tomid']);
		$v['merchname']=$v['member']['nickname'];
		$v['goods']=pdo_get('jy_goodserpfw_goods',array('uniacid'=>$_SESSION['uniacid'],'id'=>$v['goods_id']),array('id','title','pici'));
		if($v['code_type']){
			$v['pre']=pdo_getcolumn('jy_goodserpfw_batch',array('uniacid'=>$_SESSION['uniacid'],'id'=>$v['batch_id']),'xpre');
		}else{
			$v['pre']=pdo_getcolumn('jy_goodserpfw_batch',array('uniacid'=>$_SESSION['uniacid'],'id'=>$v['batch_id']),'pre');
		}
		$v['sn']=sprintf("%08d", $v['sn']);
		$v['typetitle']=$this->kulog_type[$v['type']];
		$v['createtime']=date('Y-m-d H:i:s',$v['createtime']);
	}
	$return['footernav']=array(
		array('title'=>'代理商','icon'=>'icon-shouye','action'=>'jy_goodserpfw/merch.index/'),
		array('title'=>'操作记录','icon'=>'icon-yonghujieru','action'=>'jy_goodserpfw/merch.kulog/'),
	);
	set_html('title','操作记录');
	exi($return);
}
?>